// 当前因为使用 CDN, 所以这个 JS 一般而言是不用的

let path = require('path');
let webpack = require('webpack');
// const UglifyJSPlugin = require('uglifyjs-webpack-plugin');

module.exports = {
  mode : 'production', // development | production
  entry : {
    antd : ['./src/vue/ants.js'],
    // ai : ['@ant-design/icons/lib/dist.js'],
    // af : ['ant-design-vue/lib/form/FormItem.js'],
    // ac : ['ant-design-vue/lib/vc-form/src/createBaseForm.js'],
    // am : ['ant-design-vue/lib/vc-menu/SubMenu.js'],
    // ap : ['ant-design-vue/lib/vc-pagination/Pagination.js'],
    // as : ['ant-design-vue/lib/vc-select/Select.js'],
    // async : ['async-validator/dist-web/index.js'],
    // l1 : ['ant-design-vue/lib/button/style/index.less'],
    // l2 : ['ant-design-vue/lib/grid/style/index.less'],
    // l3 : ['ant-design-vue/lib/menu/style/index.less'],
    // vue : ['vue/dist/vue.esm.js']
  },
  output : {
    filename : '_lib/_dll_[name].js',
    path : path.resolve(__dirname, 'dist'),
    library : '_dll_[name]',
    libraryTarget : 'var' // 默认就是 var
  },
  plugins : [
    new webpack.DllPlugin({
      name : '_dll_[name]', // 这个 name 要和上面的 library 相等
      path : path.resolve(__dirname, 'dist', '_lib', 'manifest_ants.json'),
      context : __dirname
    }),
    new webpack.IgnorePlugin(/\.\/locale$/, /moment$/)
  ],
  
  module : {
    noParse : /ant-design-vue/,
    rules : [
      {
        test : /\.(png|jpg|gif)$/,
        use : 'file-loader'
      },
      {
        test : /\.js$/,
        exclude : /node_modules/,
        use : [
          {
            loader : 'babel-loader',
            options : {
              presets : [
                '@babel/preset-env'/*, '@babel/preset-react'*/
              ],
              plugins : [
                '@babel/plugin-proposal-class-properties'
              ]
            }
          }
        ]
      },
      {
        test : /\.css$/,
        use : ['style-loader', 'css-loader']
      },
      {
        test : /\.less$/,
        use : 
        [
          'style-loader',
          'css-loader',
          {
            loader : 'less-loader',
            options : {
              javascriptEnabled: true
            }
          }
        ]
      }
    ]
  },

  optimization: {
    // minimizer: [
    //   new UglifyJSPlugin({
    //     uglifyOptions: {
    //       output: {
    //         comments: false
    //       },
    //       compress: {
    //         drop_debugger: true,
    //         drop_console: true
    //       }
    //     }
    //   }),
    // ],
    splitChunks: {
      chunks: 'all', // 'all' | 'async'
      // minSize: 30000,
    },
  },
};
